package com.swust.utils;

import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

public class SqlSessionFactoryUtils {
	/*不允许类外创建对象*/
	private SqlSessionFactoryUtils() {

	}
	public static SqlSessionFactory generateSqlSessionFactory() {
		//1.构建一个输入流,读取sqlMapConfig.xml文件
		InputStream is = SqlSessionFactoryUtils.class.getClassLoader().getResourceAsStream("SqlMapConfig.xml");

		//2.构建一个sqlSessionFactory工厂对象
		return new SqlSessionFactoryBuilder().build(is);
	}
}
